package com.chris.libs.devtools.x.v1.utils;

/**
 * create by Chris Chan
 * create on 2019/7/9 22:19
 * use for :尺寸工具类
 */
public class MeasureUtil extends UtilsManager {
    /**
     * todo:dp2px
     *
     * @param dpValue
     * @return
     */
    public static int dp2px(float dpValue) {
        float scale = mContext.getResources().getDisplayMetrics().density;
        return (int) (dpValue * scale + 0.5);
    }

    /**
     * todo:sp2px
     *
     * @param spValue
     * @return
     */
    public static int sp2px(float spValue) {
        float scale = mContext.getResources().getDisplayMetrics().density;
        return (int) (spValue * scale + 0.5);
    }

    /**
     * todo:px2dp
     *
     * @param pxValue
     * @return
     */
    public static int px2dp(int pxValue) {
        float scale = mContext.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5);
    }

    /**
     * todo:px2sp
     *
     * @param pxValue
     * @return
     */
    public static int px2sp(int pxValue) {
        float scale = mContext.getResources().getDisplayMetrics().density;
        return (int) (pxValue / scale + 0.5);
    }

}
